package demo3;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 30318
 * Date: 2023-05-20
 * Time: 21:42
 */
interface IFLying {
    void flying();
}

interface ISwimming {
    void swimming();
}

interface IRunning {
    void running();
}

/*class Run{
    void running{

    }
}*/

class Animal {
    public String name;
    public int age;

    public Animal(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public void eat(){
        System.out.println("吃饭");
    }
}

class Dog extends Animal implements IRunning,ISwimming {


    public Dog(String name, int age){
        super(name, age);
    }

    @Override
    public void swimming() {
        System.out.println(name + "正在游泳");
    }

    @Override
    public void running() {
        System.out.println(name + "正在跑");
    }

    @Override
    public void eat() {
        System.out.println(name + "正在吃狗粮");
    }
}

class Bird extends Animal implements IFLying{

    public Bird(String name, int age) {
        super(name, age);
    }

    @Override
    public void flying() {
        System.out.println(name + "正在飞");
    }
    @Override
    public void eat() {
        System.out.println(name + "正在吃鸟粮");
    }
}

class Duck extends Animal implements IFLying, IRunning, ISwimming{

    public Duck(String name, int age){
        super(name, age);
    }

    @Override
    public void flying() {
        System.out.println(name + "正在飞");
    }

    @Override
    public void swimming() {
        System.out.println(name + "正在游泳");
    }

    @Override
    public void running() {
        System.out.println(name + "正在跑");
    }

    @Override
    public void eat() {
        System.out.println(name + "正在吃鸭粮");
    }
}

class Robot implements IRunning{

    @Override
    public void running() {
        System.out.println("机器人正在跑");
    }
}

public class Test5 {

    public static void walk(IRunning iRunning){
        iRunning.running();
    }

    public static void func(Animal animal){
        animal.eat();
    }

    public static void main(String[] args) {
        walk(new Dog("hello",10));
        walk(new Duck("hello1", 20));
        walk(new Robot());

        System.out.println("==================");
        func(new Dog("hello",10));
        func(new Duck("hello1", 20));
    }
}
